from flask_login import LoginManager
from Modules.sys_account.model import AccountModel


login_manager = LoginManager()


@login_manager.user_loader
def load_user(user_id):
    return AccountModel.query.filter_by(id=user_id).first()


@login_manager.unauthorized_handler
def unauthorized():
    return {'code': '0x00008', 'msg': '请先登录'}